/**
 * Created by sun on 2016/8/4.
 */
define(function (require) {
    var app = require('/../js/app');
    require('ui-table');

    require('ueditor.all.min');
    require('ueditor.config');
    require('angular-ueditor');


    app.useModule("ui.table");

    app.useModule("ng.ueditor");

    var datepicker = require('datepicker');
    app.controller('siteCtrl', ['$scope','$http' ,function ($scope, $http) {
        $scope.list={};
        $scope.orderParams = {
            url: "/sys/site/list"
        };
        datepicker($scope);

        //创建
        $scope.addOrderModal=function(){
            $scope.orderModal = !$scope.orderModal ;
        };

        //全局查询
        $scope.search = function() {
            $scope.ctrlScope.trend.beginDate=$filter('date')($scope.ctrlScope.trend.beginDate,'yyyy-MM-dd');
            $scope.ctrlScope.trend.endDate=$filter('date')($scope.ctrlScope.trend.endDate,'yyyy-MM-dd');
            //表格查询参数设置
            $scope.orderParams.ajaxParam=$scope.ctrlScope.trend;
            console.info( $scope.orderParams.ajaxParam);
            //表格刷新
            $scope.orderParams.reload();
        };

        //全局查询重置
        $scope.reset=function(){

            $scope.search();
        };

        //编辑
        $scope.modifyModal=function(id){
          $scope.detailsModal= !$scope.detailsModal;
            $scope.getOne(id);
        }
        //文章查看单个
        $scope.getOne=function(id){
            $http({
                method: 'POST',
                url: "/sys/site/getSingle",
                data: {
                    nid:id
                }
            }).success(function(data) {
                console.info(data);
               $scope.list=data;
            }).error(function(data) {
            });
        }
    }]);


});